#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "opencv2/opencv.hpp"
#include <QTcpSocket>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void timerEvent(QTimerEvent *event) override;

private:
    Ui::MainWindow *ui;
    cv::VideoCapture cap;
    cv::CascadeClassifier cas;
    QTimer m_timer;//用于定时连接、重连服务器
    QTcpSocket m_socket;//客户端套接字

    bool connect_stat;//socket_连接状态
private:
    void send_img_to_server(cv::Mat &img);

    int m_delay_cnt;
private slots:
    void timer_socket_connect();
    void restart_socket_connect();
    void stop_socket_connect();
    void rcv_data();
};
#endif // MAINWINDOW_H
